package com.xbongbong.saas.domain.dao;

import com.xbongbong.saas.domain.entity.BusinessProductEntity;
import com.xbongbong.saas.domain.entity.TransferProductEntity;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/2/19 14:53
 * @since v1.0
 */

public interface TransferProductDao {

    Integer insert(TransferProductEntity transferProduct);

    Integer update(TransferProductEntity transferProduct);

    Integer deleteByKey(@Param("key") Long key, @Param("corpid") String corpid);

    Integer deleteByTransferId(@Param("transferId") Long transferId, @Param("corpid") String corpid);

    Integer deleteByTransferIdIn(@Param("transferIdIn") List<Long> transferIdIn, @Param("corpid") String corpid);

    TransferProductEntity getByKey(@Param("key") Long key, @Param("corpid") String corpid);

    List<TransferProductEntity> findEntitys(@Param("param") Map<String, Object> param);

    List<Long> findTransferIdsByRelaProNameOrNo(@Param("param") Map<String, Object> param);

    List<TransferProductEntity> findEntitysJoinProduct(@Param("param") Map<String, Object> param);

    Integer getEntitysCount(@Param("param") Map<String, Object> param);

    /**
     * 批量删除
     * @param list 数据id列表
     * @param corpid 公司id
     * @return
     */
    Integer deleteBatch(@Param("list") List<Long> list, @Param("corpid") String corpid, @Param("del") Integer del);

    List<BusinessProductEntity> findProductNum(@Param("param") Map<String,Object> param);

    Integer updateBatch(@Param("list") List<TransferProductEntity> list,@Param("corpid") String corpid);

    Integer insertBatch(@Param("list") List<TransferProductEntity> list);

    Long isProductSubAttrExist(@Param("attr") String attr, @Param("corpid") String corpid,@Param("isArray") Integer isArray);

    Integer updateOutstock(@Param("list") List<TransferProductEntity> list,@Param("corpid") String corpid);

    Integer updateInstock(@Param("list") List<TransferProductEntity> list,@Param("corpid") String corpid);

    List<String> getCorpids();

    Integer findProductNumCount(@Param("param") Map<String, Object> param);

    Double summaryByAttr(@Param("field")String field,@Param("corpid")String corpid, @Param("refId") Long refId,@Param("productIdIn") List<Long> productIdIn);

    Double summaryByAttrFromOutSide(@Param("field")String field,@Param("corpid")String corpid, @Param("refId") Long refId,@Param("productIdIn") List<Long> productIdIn);

    List<TransferProductEntity> getProductsByTransferIdIn(@Param("corpid") String corpid, @Param("transferIdIn") List<Long> TransferIdIn);

    Double calcuateByAttrFromOutSide(@Param("field1")String field1,@Param("field2") String field2,@Param("corpid") String corpid,@Param("refId") Long refId,@Param("productIdIn") List<Long> productIdIn);

    Long countProductSub(@Param("attr") String attr, @Param("corpid") String corpid, @Param("isArray") Integer isArray);

    List<TransferProductEntity> getProductWithSubData(@Param("attr") String attr, @Param("corpid") String corpid, @Param("isArray") Integer isArray, @Param("idGte") Long idGte, @Param("limit") Integer limit);

    /**
     * 批量编辑
     * @param list
     * @param corpid
     * @return
     */
    Integer updateMulti(@Param("list") List<TransferProductEntity> list, @Param("corpid") String corpid);
}
